package com.homwee.factory.pageData;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.Log;

//zcj 2018-10-30 import com.changhong.android.tvapi.common.vo.DTVSpecificProgInfo;
//zcj 2018-10-30 import com.changhong.android.tvapi.common.vo.ProgramInfo;
import com.homwee.factory.FactoryActivity;
import com.homwee.factory.R;
import com.homwee.listMenu.util.MenuItemData;

public class PageData10 extends PageData{
	private String dtvHardwareIdStr;
	private String dtvCiStateStr;
	private Context context;
	List<MenuItemData> mSubList1 =new ArrayList<MenuItemData>();
	private static final int CiNum = 17;
	private int[] cidebuglevel = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    };
	 String[] CIinfo={
			 "Resource Manager",//0
			 "Application Information",//1
			 "Conditional Access Support",//2
			 "Host Control",//3
			 "Date-Time",//4
			 "Man Machine Interface",//5
			 "Low Speed Communication",//6
			 "Content Control",//7
			 "Host Language Country",//8
			 "CAM Upgrade",//9
			 "Operator Profile",//10
			 "Specific Application Support",//11
			 "Application Man Machine Interface",//12
			 "Program Map Table(No Used)",//13
			 "Host Service Shunning",//14
			 "Canal Ready Authentication",//15
			 "Default TX/RX"//16
			
			  };
	private int monitornable = 0; //off
           
	
	public PageData10(Context context,FactoryActivity mFactoryActivity){
		super(mFactoryActivity);
		this.context = context;
	}
	
	public List<MenuItemData> LoadPageData(){
		mListItemData.clear();
		mSubList1.clear();
		try {
			
			
			MenuItemData CI_Info =new MenuItemData("CI Info");
			
//				//
//				MenuItemData mWatchDogMode =new MenuItemData(0,"Watch Dog",0,1,0,mFactoryActivity.getResources().getStringArray(R.array.factoryCloseOrOpen),1,EN_ItemType.EN_OPTIONVIEW);
//				mWhiteBalance.mInitValue =factorySetting.getWatchDogMode();
//				mWhiteBalance.setOnValueChange(new MenuItemData.onValueChange() {
//					
//					public void valueChange(int value) {
//						// TODO Auto-generated method stub
//						Log.v("tv","setWhiteBalance");
//						factorySetting.setWatchDogMode(value);
//					}
//				});	
			
			
			
//			ProgramInfo CurrProg_Info = null;
//            ProgramInfoQueryCriteria cr = new ProgramInfoQueryCriteria();
//            CurrProg_Info = TvDvbChannelManager.getInstance().getProgramInfo(cr,
//             TvDvbChannelManager.PROGRAM_INFO_TYPE_CURRENT);
//            
//            DTVSpecificProgInfo dvtSpecProgInfo = null;
//
//            dvtSpecProgInfo = mTvChannelManager.getCurrentProgramSpecificInfo();

            
		    String videoPid=factorySetting.getDVBCVideoPid()+"";
		    String AudioPid=factorySetting.getDVBCAudioPid()+"";
		    String PcrPid=factorySetting.getDVBCPcrPid()+"";
		    
		    if(!factorySetting.IsDTVSource()){
		    	videoPid="N/A";	
		    	AudioPid="N/A";
		    	PcrPid="N/A";
		    }
		    
			MenuItemData VideoPID  = new MenuItemData("V-PID", "V-PID",videoPid, MenuItemData.EN_ItemType.EN_OPTIONTEXTVIEW);
			
			
			MenuItemData AudioPID  = new MenuItemData("A-PID", "A-PID",AudioPid, MenuItemData.EN_ItemType.EN_OPTIONTEXTVIEW);
			
			
			MenuItemData PCR_PID  = new MenuItemData("PCR-PID", "PCR-PID",PcrPid, MenuItemData.EN_ItemType.EN_OPTIONTEXTVIEW);
			
			
			MenuItemData DVBCfastScan =new MenuItemData(0,"DVBC Fast Scan",0,1,0,mFactoryActivity.getResources().getStringArray(R.array.factoryCloseOrOpen),1, MenuItemData.EN_ItemType.EN_OPTIONVIEW);
			DVBCfastScan.mInitValue =factorySetting.getDVBCfastScanEnable();
			DVBCfastScan.setOnValueChange(new MenuItemData.onValueChange() {
				
				public void valueChange(int value) {
					// TODO Auto-generated method stub
					Log.v("tv","setDVBCfastScanEnable");
					factorySetting.setDVBCfastScanEnable(value);
				}
			});	
			
			
			MenuItemData DVBS_SIParserType =new MenuItemData(0,"DVBS SI Parser Type",0,1,0,mFactoryActivity.getResources().getStringArray(R.array.factoryDtvSiType),1, MenuItemData.EN_ItemType.EN_OPTIONVIEW);
			DVBS_SIParserType.mInitValue =factorySetting.getDvbsSIParserType();
			DVBS_SIParserType.setOnValueChange(new MenuItemData.onValueChange() {
				
				public void valueChange(int value) {
					// TODO Auto-generated method stub
					Log.v("tv","setDvbsSIParserType");
					factorySetting.setDvbsSIParserType(value);
				}
			});	
			
			
			MenuItemData FreeViewLogo =new MenuItemData(0,"Free View Logo",0,1,0,mFactoryActivity.getResources().getStringArray(R.array.factoryCloseOrOpen),1, MenuItemData.EN_ItemType.EN_OPTIONVIEW);
			DVBS_SIParserType.mInitValue =factorySetting.getFreeViewLogo();
			DVBS_SIParserType.setOnValueChange(new MenuItemData.onValueChange() {
				
				public void valueChange(int value) {
					// TODO Auto-generated method stub
					Log.v("tv","setFreeViewLogo");
					factorySetting.setFreeViewLogo(value);
				}
			});	
			
			
			//CI_info  17+1
			MenuItemData PerformanceMonitor =new MenuItemData(0,"Performance Monitor",0,1,0,mFactoryActivity.getResources().getStringArray(R.array.factoryCloseOrOpen),1, MenuItemData.EN_ItemType.EN_OPTIONVIEW);
			PerformanceMonitor.mInitValue =monitornable;
			PerformanceMonitor.setOnValueChange(new MenuItemData.onValueChange() {
				
				public void valueChange(int value) {
					// TODO Auto-generated method stub
					Log.v("tv","setPerformanceMonitor"+value);
					monitornable = value;
					factorySetting.setPerformanceMonitor(value);
				}
			});	
			
			
			// ci info
			 MenuItemData[] CiItemData =new MenuItemData[CiNum] ;
			 
			 for(int i=0; i<CiNum;i++){
				 
				 CiItemData[i] = new MenuItemData(0,CIinfo[i],0,4,0,1, MenuItemData.EN_ItemType.EN_OPTIONVIEW);
				 CiItemData[i].mInitValue =cidebuglevel[i];			 
			 }	
			 
			 CiItemData[0].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[0]+value);
						cidebuglevel[0] = value;
						factorySetting.setCIDebugLevel(0,value);
					}
				});
			 
			 CiItemData[1].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[1]+value);
						cidebuglevel[1] = value;
						factorySetting.setCIDebugLevel(1,value);
					}
				});
			 
			 CiItemData[2].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[2]+value);
						cidebuglevel[2] = value;
						factorySetting.setCIDebugLevel(2,value);
					}
				});
			 
			 CiItemData[3].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[3]+value);
						cidebuglevel[3] = value;
						factorySetting.setCIDebugLevel(3,value);
					}
				});
			 
			 CiItemData[4].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[4]+value);
						cidebuglevel[4] = value;
						factorySetting.setCIDebugLevel(4,value);
					}
				});
			 
			 CiItemData[5].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[5]+value);
						cidebuglevel[5] = value;
						factorySetting.setCIDebugLevel(5,value);
					}
				});
			 
			 CiItemData[6].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[6]+value);
						cidebuglevel[6] = value;
						factorySetting.setCIDebugLevel(6,value);
					}
				});
			 
			 CiItemData[7].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[7]+value);
						cidebuglevel[7] = value;
						factorySetting.setCIDebugLevel(7,value);
					}
				});
			 
			 CiItemData[8].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[8]+value);
						cidebuglevel[8] = value;
						factorySetting.setCIDebugLevel(8,value);
					}
				});
			 
			 CiItemData[9].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[9]+value);
						cidebuglevel[9] = value;
						factorySetting.setCIDebugLevel(9,value);
					}
				});
			 
			 CiItemData[10].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[10]+value);
						cidebuglevel[10] = value;
						factorySetting.setCIDebugLevel(10,value);
					}
				});
			 
			 CiItemData[11].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[11]+value);
						cidebuglevel[11] = value;
						factorySetting.setCIDebugLevel(11,value);
					}
				});
			 
			 CiItemData[12].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[12]+value);
						cidebuglevel[12] = value;
						factorySetting.setCIDebugLevel(12,value);
					}
				});
			 
			 CiItemData[13].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[13]+value);
						cidebuglevel[13] = value;
						factorySetting.setCIDebugLevel(13,value);
					}
				});
			 
			 CiItemData[14].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[14]+value);
						cidebuglevel[14] = value;
						factorySetting.setCIDebugLevel(14,value);
					}
				});
			 
			 CiItemData[15].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[15]+value);
						cidebuglevel[15] = value;
						factorySetting.setCIDebugLevel(15,value);
					}
				});
			 
			 CiItemData[16].setOnValueChange(new MenuItemData.onValueChange() {				
					public void valueChange(int value) {
						// TODO Auto-generated method stub
						Log.v("Factory",CIinfo[16]+value);
						cidebuglevel[16] = value;
						factorySetting.setCIDebugLevel(16,value);
					}
				});
			 
			// Arthur add for ISDB
			if (!factorySetting.isCurrentTvSystemIsIsdb()) {
				mListItemData.add(CI_Info);
			}
			mListItemData.add(VideoPID);
			mListItemData.add(AudioPID);
			mListItemData.add(PCR_PID);
			if (!factorySetting.isCurrentTvSystemIsIsdb()) {
				mListItemData.add(DVBCfastScan);
				mListItemData.add(DVBS_SIParserType);
				mListItemData.add(FreeViewLogo);
			}
			
			 mSubList1.add(PerformanceMonitor);
			 for(int i=0; i<CiNum;i++){
		         mSubList1.add(CiItemData[i]);
			 }
			
			
			 PerformanceMonitor.mParentGroup =mListItemData;
			 PerformanceMonitor.mParent =CI_Info;
			 CI_Info.mSubChildGroup =mSubList1;
			
			
//			String dtvCiplusStr = mFactoryActivity.getResources().getString(R.string.menu_dtv_ciplus);
//			MenuItemData dtvCiplus =new MenuItemData(dtvCiplusStr);
//			dtvCiplus.setOnEnterKey(new MenuItemData.onEnterRightKey() {
//				
//				public void onEnterRightKey() {
//					// TODO Auto-generated method stub
//					//mFactoryActivity.showMenu(false);
//					Log.v("tv","onEnterRightKey");
//				}
//			});	
//			
//			dtvHardwareIdStr=factorySetting.getDTVMidVersion();
//			MenuItemData dtvHardwareId  = new MenuItemData(dtvHardwareIdStr, mFactoryActivity.getResources()
//					.getString(R.string.factory_dtv_hardware_id),dtvHardwareIdStr,
//					EN_ItemType.EN_OPTIONTEXTVIEW);
//
//			dtvCiStateStr=factorySetting.getCIState();
//			MenuItemData dtvCiState  = new MenuItemData(dtvCiStateStr, mFactoryActivity.getResources()
//					.getString(R.string.factory_dtv_ci_state),dtvCiStateStr,
//					EN_ItemType.EN_OPTIONTEXTVIEW);
//
//			
//
//			
//			mListItemData.add(dtvCiplus);		
//			//mListItemData.add(dtvHardwareId);
//			mListItemData.add(dtvCiState);
			
		} catch (Exception e) {
			// TODO: handle exception
			Log.v("tv","Exception  factory interface! ");
		}
		
//		MenuItemData hotelVersion =null;
//		PackageManager manager = context.getPackageManager();
//		try {
//		    PackageInfo info = manager.getPackageInfo("com.changhong.commerce.service", 0);
//		    Log.v("PageData10", "versionName:" + info.versionName);//info.versionName��Ϊ�汾��
//			hotelVersion  = new MenuItemData("hotelVersion", mFactoryActivity.getResources()
//					.getString(R.string.factory_hotel_version),info.versionName,
//					EN_ItemType.EN_OPTIONTEXTVIEW);
//			
//			mListItemData.add(hotelVersion);
//		} catch (NameNotFoundException e) {
//		    e.printStackTrace();
//		}


		return mListItemData;
	}
}
